package com.zgw.his.emr.workbench;

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Scrollable;
import org.eclipse.ui.part.ViewPart;

public class PageView extends ViewPart {

	public static final String ID = "com.zgw.his.emr.workbench.PageView"; //$NON-NLS-1$
	private Composite container;
	private Scrollable scrool;
	private ScrolledComposite scrolledComposite;
	private Color COLOR_BACK = new Color(Display.getDefault(), 131, 143, 163);

	public PageView() {
	}

	/**
	 * Create contents of the view part.
	 * 
	 * @param parent
	 */
	@Override
	public void createPartControl(Composite parent) {
		{
			scrolledComposite = new ScrolledComposite(parent, SWT.BORDER
					| SWT.H_SCROLL | SWT.V_SCROLL);
			scrolledComposite.setBounds(348, 267, 85, 85);
			scrolledComposite.setExpandHorizontal(true);
			scrolledComposite.setExpandVertical(true);
			{
				container = new Composite(scrolledComposite, SWT.NONE);
				container.setBackground(COLOR_BACK);
			}
			scrolledComposite.setContent(container);
			scrolledComposite.setBackground(COLOR_BACK);
			parent.setBackground(COLOR_BACK);

		}
		createActions();
		initializeToolBar();
		initializeMenu();
	}

	/**
	 * Create the actions.
	 */
	private void createActions() {
		// Create the actions
	}

	/**
	 * Initialize the toolbar.
	 */
	private void initializeToolBar() {
		IToolBarManager toolbarManager = getViewSite().getActionBars()
				.getToolBarManager();
	}

	/**
	 * Initialize the menu.
	 */
	private void initializeMenu() {
		IMenuManager menuManager = getViewSite().getActionBars()
				.getMenuManager();
	}

	@Override
	public void setFocus() {
		// Set the focus
	}

	public Composite getContainer() {
		return container;
	}

	public void layout() {
		if (container.getChildren().length > 0) {
			Control c = scrolledComposite.getChildren()[0];
			// scrolledComposite.setContent(c);
			Point p = c.computeSize(SWT.DEFAULT, SWT.DEFAULT);
			scrolledComposite.setMinSize(new Point(p.x, p.y + 20));
		}
	}

	public void setName(String name) {
		setPartName(name);
	}

}
